<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui"
	template="/template/template.xhtml" xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
#searchInput {
	padding: 21px;
}

.ui-datatable-scrollable-header-box {
	margin-left: 0px;
	margin-right: 15px !important;
}
</style>
	</ui:define>
	<ui:define name="content">
		<div class="box box-solid with-border">
			<div class="nav-tabs-custom" id="alarm1" style="position: relative">
				<ul class="nav nav-tabs pull-left">
					<li class="active"><a href="#scheduleShow" data-toggle="tab" onclick="refresh1()">值班信息查看</a></li>
					<li><a href="#rotaPerson" data-toggle="tab" onclick="refresh()">周末值班表</a></li>
					<li><a href="#rotaOrder" data-toggle="tab" onclick="refresh()">轮值表</a></li>
				</ul>
				<h:form>
					<p:remoteCommand name="refresh" update="rotaPersonForm rotaForm"
						oncomplete="getTableScrollHeight();"></p:remoteCommand>
					<p:remoteCommand name="refresh1" update="form" oncomplete="resizeSlimScrollDiv()"></p:remoteCommand>
				</h:form>
				<div class="tab-content no-padding">
					<div id="scheduleShow" class="chart tab-pane active">
						<div class='full-center-content-scroll-noheader' >
							<h:form id="form">
								<p:growl id="msgs" showDetail="true" />
								<p:confirmDialog global="true" showEffect="clip" hideEffect="clip">
									<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes"
										icon="ui-icon-check" />
									<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no"
										icon="ui-icon-close" />
								</p:confirmDialog>
								<h:panelGrid columnClasses="value">
									<h4 style="margin-top: 2">继电保护处值班信息</h4>
									<p:schedule id="schedule" value="#{rotaController.lazyEventModel}" widgetVar="myschedule"
										timeZone="GMT+2" style="width:98%">
										<p:ajax event="eventSelect" listener="#{rotaController.onEventSelect}"
											update="schedule :form2:rotaDialog" oncomplete="PF('rotaDialog').show();" />
									</p:schedule>
								</h:panelGrid>
							</h:form>
							<h:form id="form2">
								<!-- eventSelect -->
								<p:dialog widgetVar="rotaDialog" header="值班人员信息" modal="true" id="rotaDialog" width="350"
									height="250">
									<p:toolbar id="toolBar" rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_zbryxx_bc')}">
										<f:facet name="left">
											<p:commandButton value="保存" icon="ui-icon-disk"
												rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_zbryxx_bc')}"
												actionListener="#{rotaController.saveRotaPerson}"
												update=":rotaForm:msgs :form:schedule toolBar" oncomplete="PF('rotaDialog').hide()" />
										</f:facet>
									</p:toolbar>
									<p:outputPanel style="text-align:center;">
										<p:panelGrid columns="2">
											<h:outputText value="值班人" />
											<p:selectOneMenu id="rotaOrder" value="#{rotaController.rotaOrder.personName}"
												style="width:98%">
												<f:selectItem itemLabel="#{rotaController.rotaPerson.personName}" />
												<f:selectItems value="#{rotaController.rotaOrders}" />
											</p:selectOneMenu>
											<h:outputText value="值班日期：" />
											<p:calendar id="date" navigator="true" value="#{rotaController.rotaPerson.rotaDate}" />
											<h:outputText value="备注" />
											<p:selectOneMenu id="console" value="#{rotaController.rotaPerson.remark}"
												style="width:98%">
												<f:selectItem itemLabel="请选择" itemValue="" />
												<f:selectItem itemLabel="周六" itemValue="周六" />
												<f:selectItem itemLabel="周日" itemValue="周日" />
											</p:selectOneMenu>
										</p:panelGrid>
									</p:outputPanel>
								</p:dialog>
							</h:form>
						</div>
					</div>
					<!-- rotaPerson table begin -->

					<div id="rotaPerson" class="chart tab-pane" style="position: relative">
						<h:form id="rotaPersonForm">
							<p:growl id="rpmsgs" showDetail="true" />
							<p:confirmDialog global="true" showEffect="clip" hideEffect="clip">
								<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes"
									icon="ui-icon-check" />
								<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no"
									icon="ui-icon-close" />
							</p:confirmDialog>
							<div class="box box-solid with-border">
								<div class="box-header">
									<p:outputLabel for="popup5" value="值班日期：" />
									<p:calendar id="popup5" navigator="true" value="#{rotaController.rotaDate}"
										pattern="yyyy-MM-dd">
									</p:calendar>
									<p:commandButton value="查询" id="query2" update="rotaPersonTable" icon="ui-icon-search"
										actionListener="#{rotaController.queryByTime}" style="margin-left:5px;">
									</p:commandButton>
									<p:commandButton value="重置" update="rotaPersonTable popup5" icon="ui-icon-refresh"
										actionListener="#{rotaController.findAll}" style="margin-left:5px;">
									</p:commandButton>
								</div>
							</div>
							<p:toolbar id="toolbar">
								<f:facet name="left">
									<p:commandButton value="初始化周末值班表"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_zmzbb_cshzmzbb')}" id="reInitBtn"
										oncomplete="PF('reInitOpDlg').show()" update="reInitOpDlg" />
									<p:commandButton value="新建" icon="fa fa-plus"
										actionListener="#{rotaController.preCreateRotaPerson}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_zmzbb_xj')}"
										oncomplete="PF('createRotaPersonDlg').show()" update="createRotaPersonDlg" />
									<p:commandButton value="编辑" icon="fa fa-pencil" id="editRpBtn"
										actionListener="#{rotaController.preEditRotaPerson}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_zmzbb_bj')}"
										oncomplete="PF('createRotaPersonDlg').show()"
										disabled="#{rotaController.selectRotaPerson.id == null}"
										update="createRotaPersonDlg rotaPersonTable" />
									<p:commandButton value="删除" icon="fa fa-trash" id="deltRpBtn"
										update="rpmsgs rotaPersonTable editRpBtn deltRpBtn"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_zmzbb_sc')}"
										disabled="#{rotaController.selectRotaPerson.id == null}"
										actionListener="#{rotaController.deleteRotaPerson}">
										<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
									</p:commandButton>
								</f:facet>
							</p:toolbar>
							<p:dataTable id="rotaPersonTable" value="#{rotaController.rotaPersons}" var="rotaPerson"
								paginator="true" emptyMessage="无记录" rowKey="#{rotaPerson.id}" rowIndexVar="ite" rows="20"
								paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="20,50,100" paginatorPosition="bottom"
								style="text-align:center;margin-top:3px" scrollable="true">
								<f:facet name="{Customization}">
									<p:outputLabel value="总计：#{rotaController.rotaPersons.size()} 条记录"
										style="margin-right:20px;" />
								</f:facet>
								<p:ajax event="rowSelectRadio" update="rotaPersonForm"
									listener="#{rotaController.onRotaPersonSelect}" />
								<p:column selectionMode="single" width="5%" style="text-align:center" />
								<p:column width="5%" headerText="序号 ">
									<h:outputText value="#{ite+1}" />
								</p:column>
								<p:column headerText="用户Code" width="15%">
									<p:outputLabel value="#{rotaPerson.personId}" />
								</p:column>
								<p:column headerText="姓名" width="15%">
									<p:outputLabel value="#{rotaPerson.personName}" />
								</p:column>
								<p:column headerText="值班日期" width="20%">
									<p:outputLabel value="#{rotaController.formatterDate(rotaPerson.rotaDate)}" />
								</p:column>
								<p:column headerText="备注" width="30%">
									<p:outputLabel value="#{rotaPerson.remark}" />
								</p:column>
								<p:column headerText="年份" width="10%">
									<p:outputLabel value="#{rotaPerson.year}" />
								</p:column>
							</p:dataTable>
							<p:dialog widgetVar="createRotaPersonDlg" header="值班人员信息" modal="true"
								id="createRotaPersonDlg" width="350" height="250">
								<p:toolbar id="saveToolbar">
									<f:facet name="left">
										<p:commandButton value="保存" icon="ui-icon-disk"
											actionListener="#{rotaController.saveRotaPerson}"
											update="rpmsgs createRotaPersonDlg rotaPersonTable toolbar"
											oncomplete="PF('createRotaPersonDlg').hide()" />
									</f:facet>
								</p:toolbar>
								<p:outputPanel style="text-align:center;">
									<p:panelGrid columns="2">
										<h:outputText value="当前值班人" />
										<p:inputText label="content" readonly="true"
											value="#{rotaController.rotaPerson.personName}" />
										<h:outputText value="备选值班人" />
										<p:selectOneMenu id="rotaOrder" value="#{rotaController.rotaOrder.personName}"
											style="width:98%">
											<f:selectItem itemLabel="请选择" itemValue="" />
											<f:selectItems value="#{rotaController.rotaOrders}" />
										</p:selectOneMenu>
										<h:outputText value="值班时间：" />
										<p:calendar id="date" navigator="true" value="#{rotaController.rotaPerson.rotaDate}"
											pattern="yyyy-MM-dd" />
										<h:outputText value="备注" />
										<p:selectOneMenu id="console" value="#{rotaController.rotaPerson.remark}"
											style="width:98%">
											<f:selectItem itemLabel="请选择" itemValue="" />
											<f:selectItem itemLabel="周六" itemValue="周六" />
											<f:selectItem itemLabel="周日" itemValue="周日" />
										</p:selectOneMenu>
									</p:panelGrid>
								</p:outputPanel>
							</p:dialog>
							<p:dialog widgetVar="reInitOpDlg" header="初始化周末值班表" modal="true" id="reInitOpDlg" width="350"
								height="200">
								<p:toolbar id="reInitToolbar">
									<f:facet name="left">
										<p:commandButton value="执行" icon="ui-icon-disk" id="initBtn"
											update="rpmsgs rotaPersonTable" actionListener="#{rotaController.reInitRotaPersonInfo}"
											oncomplete="PF('reInitOpDlg').hide()">
											<p:confirm header="提示" message="初始化值班表后,原值班表信息将被删除,确定初始化吗?" icon="ui-icon-alert" />
										</p:commandButton>
									</f:facet>
								</p:toolbar>
								<p:outputPanel style="text-align:center;">
									<p:panelGrid columns="2" style="width:100%">
										<h:outputText value="轮值顺序" />
										<h:selectOneMenu value="#{rotaController.roundRule}" style="width:150px;height:30px">
											<f:selectItem itemLabel="请选择" itemValue="0" />
											<f:selectItem itemLabel="姓氏正序" itemValue="0" />
											<f:selectItem itemLabel="姓氏逆序" itemValue="1" />
										</h:selectOneMenu>
										<h:outputText value="年份" />
										<h:selectOneMenu value="#{rotaController.year}" style="width:150px;height:30px">
											<f:selectItem itemLabel="请选择" itemValue="0" />
											<f:selectItem itemLabel="2018年" itemValue="2018" />
											<f:selectItem itemLabel="2019年" itemValue="2019" />
											<f:selectItem itemLabel="2020年" itemValue="2020" />
											<f:selectItem itemLabel="2021年" itemValue="2021" />
											<f:selectItem itemLabel="2022年" itemValue="2022" />
											<f:selectItem itemLabel="2023年" itemValue="2023" />
											<f:selectItem itemLabel="2024年" itemValue="2024" />
											<f:selectItem itemLabel="2025年" itemValue="2025" />
										</h:selectOneMenu>
									</p:panelGrid>
								</p:outputPanel>
							</p:dialog>
						</h:form>
					</div>

					<!-- rotaPerson table end -->

					<div id="rotaOrder" class="chart tab-pane">
						<h:form id="rotaForm">
							<p:confirmDialog global="true" showEffect="clip" hideEffect="clip">
								<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes"
									icon="ui-icon-check" />
								<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no"
									icon="ui-icon-close" />
							</p:confirmDialog>
							<p:growl id="msgs" showDetail="true" />
							<p:toolbar id="toolbar">
								<f:facet name="left">
									<p:commandButton value="初始化轮值表" oncomplete="PF('details').show()"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_lzb_cshlzb')}" />
									<p:commandButton value="新建" icon="fa fa-plus"
										actionListener="#{rotaController.preCreateRotaOrder}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_lzb_xj')}"
										oncomplete="PF('createDlg').show()" update="createDlg" />
									<p:commandButton value="编辑" icon="fa fa-pencil" id="editBtn"
										actionListener="#{rotaController.preEditRotaOrder}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_lzb_bj')}"
										oncomplete="PF('createDlg').show()"
										disabled="#{rotaController.selectRotaOrder.id == null}" update="createDlg rotaTable" />
									<p:commandButton value="删除" icon="fa fa-trash" id="deltBtn"
										update="msgs rotaTable editBtn deltBtn"
										disabled="#{rotaController.selectRotaOrder.id == null}"
										rendered="#{s:hasPermission(session,'gzgl_zbgl_zmzb_lzb_sc')}"
										actionListener="#{rotaController.deleteRotaOrder}">
										<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
									</p:commandButton>
									<!-- <p:commandButton value="逆序排列"  id="reorder"
										update="msgs rotaTable editBtn deltBtn"
										actionListener="#{rotaController.reOrder}">
									</p:commandButton> -->
								</f:facet>
							</p:toolbar>
							<p:dataTable id="rotaTable" value="#{rotaController.rotaOrders}" var="rotaOrder"
								paginator="true" emptyMessage="无记录" rowKey="#{rotaOrder.id}" rowIndexVar="ite" rows="20"
								paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="20,50,100" paginatorPosition="bottom"
								style="text-align:center;margin-top:3px" scrollable="true">
								<f:facet name="{Customization}">
									<p:outputLabel value="总计：#{rotaController.rotaOrders.size()} 条记录"
										style="margin-right:20px;" />
								</f:facet>
								<p:ajax event="rowSelectRadio" update="rotaForm"
									listener="#{rotaController.onRotaOrderSelect}" />
								<p:column selectionMode="single" width="5%" style="text-align:center" />
								<p:column width="5%" headerText="序号 ">
									<h:outputText value="#{ite+1}" />
								</p:column>
								<p:column headerText="值班序号" width="45%">
									<p:outputLabel value="#{rotaOrder.rotaOrder}" />
								</p:column>
								<p:column headerText="值班人" width="45%">
									<p:outputLabel value="#{rotaOrder.personName}" />
								</p:column>
							</p:dataTable>
							<p:dialog widgetVar="createDlg" header="值班信息" modal="true" id="createDlg" width="350"
								height="250">
								<p:toolbar id="saveToolbar">
									<f:facet name="left">
										<p:commandButton value="保存" icon="ui-icon-disk"
											actionListener="#{rotaController.saveRotaOrder}" update="msgs rotaTable toolbar"
											oncomplete="PF('createDlg').hide()" />
									</f:facet>
								</p:toolbar>
								<p:outputPanel style="text-align:center;">
									<p:panelGrid columns="2">
										<h:outputText value="值班序号" />
										<p:inputText label="content" value="#{rotaController.rotaOrder.rotaOrder}" />
										<h:outputText value="值班人用户名" />
										<p:inputText label="content" value="#{rotaController.rotaOrder.personName}" />
									</p:panelGrid>
								</p:outputPanel>
							</p:dialog>
							<p:dialog widgetVar="details" width="300" height="100" id="details" header="周末轮值人员"
								resizable="false" modal="true" showEffect="fade" hideEffect="fade">
								<p:outputLabel style="color:red" value="初始化轮值表后,原轮值表信息将被删除,确定选择吗?"></p:outputLabel>
								<p:commandButton value="选择" icon="ui-icon-extlink"
									actionListener="#{rotaController.initRotaOrder()}">
									<p:ajax event="dialogReturn" oncomplete="PF('details').hide()"
										listener="#{rotaController.onUsersChosen}" update="msgs,rotaTable" />
								</p:commandButton>
							</p:dialog>
						</h:form>
					</div>
				</div>
			</div>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/js/tables/tabScrollTable.js" />
		<script>
			var scheduleShowH = 0;
			jQuery(document).ready(function($) {
				scheduleShowH = parseInt($("#scheduleShow").css("height"));
				resizeSlimScrollDiv();
			});

			function resizeSlimScrollDiv() {
				var obj = $('.slimScrollDiv').each(function() {
					this.style.height = scheduleShowH - 50 + "px";
				});
			}
		</script>
	</ui:define>
</ui:composition>
